Object.prototype.myAssign = function (target, ...srcObj) {
    for (let i = 0; i < srcObj.length; i++){
        if (srcObj[i] !== null || srcObj[i] !== undefined) {
            for (let key in target) {
                if (srcObj[i].hasOwnProperty(key)) {
                    target[key] = srcObj[i][key]
                }
            }
        }
    }
    return target
}

let obj1 = {
	name: "xxx",
	age: 10,
	subject: {
		name: "aaa",
		score: 100,
	},
	sex: "male",
};
let obj2 = {
	name: "ccc",
	age: 19,
    subject: {
		name: "bbb",
		score: 100,
	},
};
console.log(Object.myAssign(obj1, obj2)); 